function [newTour, newOriginal]=insertNewTour(X, Y, tour, original, sites, edges, triangles, siteGrid, triangleGrid)

numTours=length(X)/3;
newTour=[];
newOriginal=[];

for i=1:numTours-1
    newTour=[newTour; tour(i,:);];
    newOriginal=[newOriginal; original(i)];
    %the three control points
    P=X((3*i-2):(3*i)); 
    Q=Y((3*i-2):(3*i)); 
    R=X((3*i+1):(3*i+3));
    if violation(P,Q,R,sites, triangles, triangleGrid)
        newX=findValley(P, R, sites, edges, siteGrid);
        if ~isempty(newX)
            newTour=[newTour; newX'];
            newOriginal=[newOriginal; 0];
        end
    end
end

newTour=[newTour; tour(numTours,:)];
newOriginal=[newOriginal; original(numTours)];


